package com.gonsin.license;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.i18n.CookieLocaleResolver;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;

import java.io.File;
import java.util.Locale;

@Configuration
public class LicenseMvcConfig implements WebMvcConfigurer {

    @Autowired private LicenseInterceptor licenseInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(licenseInterceptor)
                .addPathPatterns("/**")
                // 排除
                .excludePathPatterns("/license")
                .excludePathPatterns("/**/license")
                .excludePathPatterns("/license/**")
                .excludePathPatterns("/api/licensed")
                .excludePathPatterns("/api/license/online")
                .excludePathPatterns("/api/upload_license");
    }
}
